<?php
//recherche des package
foreach ($_SESSION['install']['packages'] as $package)
{
	$xml = file_get_contents($package['host'].'index.php?application='.$package['name'].'&action=needed_versions&version='.$package['old_version']);
	$_SESSION['install']['packages_versions'] = array();
	if($xml!='')
	{
		$data = @new SimpleXMLElement($xml);
		if($package['name'] == ''.$data->application[0]->name[0])
		{
			if($package['old_version'] == ''.$data->application[0]->packages[0]['since'])
			{
				$versions = array();
				foreach($data->application[0]->packages[0]->package as $xmlPackage)
				{
					$versions[] = $package['name'].'___'.$xmlPackage->version[0];
					$_SESSION['install']['packages_versions'][] = array(
						'host' => $package['host']
						, 'name' => $package['name']
						, 'version' => ''.$xmlPackage->version[0]
						, 'size' => ''.$xmlPackage->size[0]
						, 'md5' => ''.$xmlPackage->md5[0]
						);
				}
				$_SESSION['install']['progress'] = 0;
				$_SESSION['install']['status'] = '';
				$_SESSION['install']['screen'] = 1;
				if(count($versions)>0)
				{
					echo '
update_dico["download"] = "«!ADMIN_UPDATE_TOOLTIPS_DOWNLOAD»";
update_dico["check"] = "«!ADMIN_UPDATE_TOOLTIPS_CHECK»";
update_dico["requirement"] = "«!ADMIN_UPDATE_TOOLTIPS_REQUIREMENT»";
update_dico["extract"] = "«!ADMIN_UPDATE_TOOLTIPS_EXTRACT»";
update_dico["sql"] = "«!ADMIN_UPDATE_TOOLTIPS_SQL»";
update_dico["scripts"] = "«!ADMIN_UPDATE_TOOLTIPS_SCRIPTS»";
updateDisplayVersions(new Array("'.implode('","', $versions).'"));
updateUpdateStepCurrent(null, null, 1);';
				}
				echo 'updatePerform("'.$_SESSION['install']['id'].'", "«!ADMIN_INSTALL_DOWNLOAD_HEAD»", " ");
updateStartProgress()';
			}
			else
			{
				echo 'updateDisplayError("«!ADMIN_INSTALL_ERROR_BADVERSION»");';
			}
		}
		else
		{
			echo 'updateDisplayError("«!ADMIN_INSTALL_ERROR_BADAPPLICATION»");';
		}
	}
	else
	{
		echo 'updateDisplayError("«!ADMIN_INSTALL_ERROR_INDEXEMPTY»");';
	}
}
?>